﻿using M_Manufacture.API.Application.Command.ProductionPlanCommand;
using M_Manufacture.Domain;
using M_Manufacture.Repository.Interface;
using MediatR;

namespace M_Manufacture.API.Application.CommandHandlers.ProductionPlanCommandHandler
{
    /// <summary>
    /// 反填生产计划
    /// </summary>
    public class GetByidCommandHandler : IRequestHandler<GetByidCommand, ProductionPlan>
    {
        /// <summary>
        /// 生产计划仓储接口
        /// </summary>
        protected readonly IProductionPlanRepository productionPlanRepository;

        public GetByidCommandHandler(IProductionPlanRepository productionPlanRepository)
        {
            this.productionPlanRepository = productionPlanRepository;
        }

        public async Task<ProductionPlan> Handle(GetByidCommand request, CancellationToken cancellationToken)
        {
            return await productionPlanRepository.GetModelsAsync(request.ProductionPlanId);
        }
    }
}
